package br.com.curso.builder;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class NotaFiscalBuilder {

	private String razaoSocial;
	private String cnpj;
	private double valorBruto;
	private double impostos;
	private Calendar dataEmissao;
	private String observacoes;
	private List<ItemDaNota> itens = new ArrayList<ItemDaNota>();

	public NotaFiscalBuilder() {
		dataEmissao = Calendar.getInstance();
	}
	
	public NotaFiscalBuilder comRazaoSocial(String razao) {
		razaoSocial = razao;
		return this;
	}
	
	public NotaFiscalBuilder comCnpj(String cnpj) {
		this.cnpj = cnpj;
		return this;
	}
	
	public NotaFiscalBuilder com(ItemDaNota item) {
		itens.add(item);
		valorBruto += item.getValor();
		impostos += item.getValor() * 0.05;
		return this;
	}
	
	public NotaFiscalBuilder naData(Calendar data) {
		dataEmissao = data;
		return this;
	}
	
	public NotaFiscalBuilder comObservacoes(String obs) {
		observacoes = obs;
		return this;
	}
	
	
	public NotaFiscal criarNotafiscal() {
		return new NotaFiscal(razaoSocial, cnpj,valorBruto,impostos, dataEmissao, observacoes, itens);
	}
	
 }
